import request from "@/utils/request";

enum API {
    ALLROLE_URL = '/admin/acl/role/',
    ADDROLE_URL = '/admin/acl/role/save',
    UPDATEROLE_URL = '/admin/acl/role/update',
    ALLPERMISSTION_URL = '/admin/acl/permission/toAssign/',
    SETPERMISSTION_URL = '/admin/acl/permission/doAssign/?',
    REMOVEROLE_URL = '/admin/acl/role/remove/'
}

// 获取全部的角色
export const reqAllRoleList = (page: any, limit: any, roleName: any) => request.get<any, any>(API.ALLROLE_URL + `${page}/${limit}/?roleName=${roleName}`)

// 添加职位与更新职位的接口
export const reqAddOrUpdateRole = (data: any) => {
    if (data.id) {
        return request.put<any, any>(API.UPDATEROLE_URL, data)
    } else {
        return request.post<any, any>(API.ADDROLE_URL, data)
    }
}

// 获取全部菜单与按钮权限的数据
export const reqAllMenuList = (roleId: any) => request.get<any, any>(API.ALLPERMISSTION_URL + roleId)

// 给相应的职位下发权限
export const reqSetPermissstion = (roleId: any, permissionId: any) => request.post<any, any>(API.SETPERMISSTION_URL + `roleId=${roleId}&permissionId=${permissionId}`)

// 删除已有职位的方法
export const reqRomoveRole = (id: any) => request.delete<any, any>(API.REMOVEROLE_URL + id)























